package com.example.demo.controller;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.baomidou.lock.annotation.Lock4j;
import com.example.demo.annotion.Test;
import com.example.demo.service.TestService;
import com.sun.xml.internal.bind.v2.runtime.Coordinator;
import lombok.extern.slf4j.Slf4j;
import org.gavaghan.geodesy.Ellipsoid;
import org.gavaghan.geodesy.GeodeticCalculator;
import org.gavaghan.geodesy.GeodeticCurve;
import org.gavaghan.geodesy.GlobalCoordinates;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class TestController {

    @Autowired
    private TestService testService;

    @Lock4j
    @GetMapping("/index")
    public String index(){
        try {
            Thread.sleep(6000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        String rs = "hello";
        log.info("rs:{}",rs);
        return rs;
    }

    @GetMapping("/geo")
    public String geo(){
        GlobalCoordinates store = new GlobalCoordinates(30.484894,114.436579);
        GlobalCoordinates userPoint =  new GlobalCoordinates(30.487003,114.431729);

        GeodeticCurve geodeticCurve =new GeodeticCalculator().calculateGeodeticCurve(Ellipsoid.ANS,store,userPoint);
        double rs = geodeticCurve.getEllipsoidalDistance();
        return String.valueOf(rs);
    }

}
